/*
	@file : PerfScope.cpp
	@author : Wolfhead
*/
#include "perf/PerfScope.h"
#include "perf/PerfManager.h"
#include "detail/Singleton.h"

namespace logger
{
namespace perf
{

template<typename IdentifierType>
LogPerfScope::LogPerfScope(IdentifierType id, const std::string& message)
	: m_perf(Singleton<PerfManager<IdentifierType> >::instance().GetPerfObject())
{
	m_start_time = boost::posix_time::microsec_clock::local_time();
	m_perf.step_in(m_start_time, message);
}

LogPerfScope::~LogPerfScope()
{
	boost::posix_time::ptime end_time = boost::posix_time::microsec_clock::local_time();
	m_perf.step_out(end_time, end_time - m_start_time);
}


}//namespace perf
}//namespace logger